{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<div class="space-10"></div>
<div class="set-style">
	<dl>
		<dt><span class="required">*</span>理财名称：</dt>
		<dd>
			<input type="text" id="level_name" value="{$info.level_name}" class="input-common">
			<p class="error">请输入理财名称</p>
			<p class="hint">设置理财名称</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>收益率:</dt>
		<dd>
			<input type="number" id="price"  value="{$info.price}" class="input-common">
			<p class="error">收益率</p>
			<p class="hint">设置收益率</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>理财周期:</dt>
		<dd>
			<input type="number" id="all_day"  value="{$info.all_day}" class="input-common">
			<p class="error">天</p>
			<p class="hint">设置理财周期</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>单次最低购买:</dt>
		<dd>
			<input type="number" id="hour_product"  value="{$info.hour_product}" class="input-common">
			<p class="error">请输入最低购买金额</p>
			<p class="hint">设置小时产量金额</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>单次最高购买:</dt>
		<dd>
			<input type="number" id="day_product"  value="{$info.day_product}"  class="input-common">
			<p class="error">请输入最高购买金额</p>
			<p class="hint">设置最高购买金额</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>可买次数:</dt>
		<dd>
			<input type="number" id="can_buy"  value="{$info.can_buy}" class="input-common">
			<p class="error">G</p>
			<p class="hint">会员可以购买的次数</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>最高上限:</dt>
		<dd>
			<input type="number" id="total_product"  value="{$info.total_product}" class="input-common">
			<p class="error">请输入购买最高上限</p>
			<p class="hint">设置总最高上限</p>
		</dd>
	</dl>

	<dl>
		<dt><span class="required">*</span>产品提供方:</dt>
		<dd>
			<input type="text" id="product_give"  value="{$info.product_give}" class="input-common">
			<p class="error">请输入总产量</p>
			<p class="hint">设置总产量</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>产品说明:</dt>
		<dd>
			<input type="text" id="product_desc"  value="{$info.product_desc}" class="input-common">
			<p class="error">请输入产品说明</p>
			<p class="hint">设置产品说明</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>购买增加算力:</dt>
		<dd>
			<input type="number" id="add_hash"  value="{$info.add_hash}" class="input-common">
			<p class="error">G</p>
			<p class="hint">设置购买后增加的算力</p>
		</dd>
	</dl>
	<dl>
		<dt>理财图片：</dt>
		<dd>
			<div class="upload-btn-common">
				<div>
					<input class="input-file" name="file_upload" id="uploadImgweb_qrcode" type="file" onchange="imgUpload(this);" title="上传">
					<input type="hidden" id="mill_pic" value="{$info.mill_pic}" />
				</div>
				<input type="text" id="text_mill_pic" class="input-common" readonly="readonly" value="{$info.mill_pic}" />
				<em>上传</em>

				<img id="preview_web_qrcode" src="__STATIC__/blue/img/upload-common-select.png" data-html="true" data-container="body" data-placement="top" data-trigger="manual"/>

			</div>

			<p class="hint">
				<span>建议使用<i class="important-note">宽100</i>像素-<i class="important-note">高100</i>像素内的<i class="important-note">GIF</i>或<i class="important-note">PNG</i>透明图片</span>
			</p>

		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>状态:</dt>
		<dd>
			<input id="status" type="checkbox"  {if condition="$info['status'] eq 1"}checked{/if}  class="checkbox" />
			<p class="hint">设置启用状态</p>
		</dd>
	</dl>
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="addGift();">保存</button>
			<button class="btn-common-cancle btn-big" onclick="javascript:history.back(-1);" >返回</button>
		</dd>
	</dl>
</div>
<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>
//保存
function addGift(){
	var level_id = {$info.level_id};
	var level_name = $("#level_name").val();
	var day_product = $("#day_product").val();
	var total_product = $("#total_product").val();
    var hour_product = $("#hour_product").val();
	var mill_pic = $("#mill_pic").val();
    var price = $("#price").val();
    var add_hash =  $("#add_hash").val();
    var all_day = $("#all_day").val();
    var can_buy = $("#can_buy").val();
	var status =  $("#status").prop('checked') ? 1 : 0 ;
	var product_give = $("#product_give").val();
	var product_desc = $("#product_desc").val();

	if (level_name == '') {
		$("#level_name").next().show().css("display","inline-block");
		$("#level_name").focus();
		return false;
	} else {
		$(".error").hide();
	}

	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/Mine/millLevelModify')}",
		data : {
			'level_id':level_id,
			'level_name' : level_name,
			'day_product' : day_product,
			'total_product' : total_product,
            'mill_pic' : mill_pic,
			'hour_product' : hour_product,
			'add_hash' : add_hash,
			'price' :price,
			'all_day':all_day,
			'can_buy':can_buy,
			'status' :status,
			'product_give':product_give,
			'product_desc':product_desc
		},
		success : function(data) {
			if (data["code"] > 0) {
				showTip(data['message'],'success');
				location.href=__URL("ADMIN_MAIN/Mine/millLevelList");
			}else{
				showTip(data['message'],'error');
			}
		}
	});
}

function imgUpload(event) {
	var fileid = $(event).attr("id");
	var id = $(event).next().attr("id");
	var data = { 'file_path' : "config" };
	uploadFile({
		url: __URL(ADMINMAIN + '/millLevel/uploadimage'),
		fileId: fileid,
		data : data,
		callBack: function (res) {
			if(res.code){
				$("#"+id).val(res.data.path);
				$("#text_" + id).val(res.data.path);
				$("#preview_" + id).attr("data-src",__IMG(res.data.path));
				showTip(res.message,"success");
			}else{
				showTip(res.message,"error");
			}
		}
	});
}
</script>
{/block}